#pragma once

#include <cstdio>

namespace MockItNow
{
	template<typename T>
	class LinkedList
	{
	public:
	
		LinkedList()
		: m_head(0),
		  m_tail(0)
		{
		}

		~LinkedList()
		{
			Clear();
		}

		void Clear()
		{
			T* item = m_head;

			while(item != 0)
			{
				T* next = item->next;
				delete item;
				item = next;
			}

			m_head = NULL;
			m_tail = NULL;
		}

		void Add(T* item)
		{
			if (m_head == 0)
			{
				m_head = item;
				m_tail = item;
				return;
			}

			m_tail->next = item;

			m_tail = item;
		}

		T* GetHead() const
		{
			return m_head;
		}

		T* GetTail() const
		{
			return m_tail;
		}

	private:

		T* m_head;
		T* m_tail;
	};
}
